import { create } from 'zustand';
import { persist } from 'zustand/middleware';

export interface Settings {
  baseUrl: string;
  apiKey: string;
  model: string;
  temperature: number;
}

interface SettingsStore {
  settings: Settings;
  updateSettings: (settings: Partial<Settings>) => void;
}

const defaultSettings: Settings = {
  baseUrl: '/aliyun',
  apiKey: 'sk-b7cb6e885efd45029f850733d6d2101f',
  model: 'deepseek-r1',
  temperature: 0.7,
};

export const useSettingsStore = create<SettingsStore>()(
  persist(
    (set) => ({
      settings: defaultSettings,
      updateSettings: (newSettings) =>
        set((state) => ({
          settings: { ...state.settings, ...newSettings },
        })),
    }),
    {
      name: 'settings-storage',
    }
  )
); 